﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_MessageReply : IBLL_MessageReply
    {
        Common common = new Common();
        private static readonly IDAL_MessageReply dal = DataAccess.Create_MessageReply();
        //D_FIM_MAS_Receives r = new D_FIM_MAS_Receives();

        public B_MessageReply()
        {

        }

        public IList<M_MessageReply> GetFull(string to_emp_seq
            , string from_emp_seq, string message_status)
        {
            Nullable<int> nto_emp_seq = common.ConvertNullInt(to_emp_seq);
            Nullable<int> nfrom_emp_seq = common.ConvertNullInt(from_emp_seq);
            return dal.GetFull(nto_emp_seq, nfrom_emp_seq, message_status);
        }

        public IList<M_MessageReply> GetList(string to_emp_seq
            , string from_emp_seq, string message_status)
        {
            Nullable<int> nto_emp_seq = common.ConvertNullInt(to_emp_seq);
            Nullable<int> nfrom_emp_seq = common.ConvertNullInt(from_emp_seq);
            return dal.GetList(nto_emp_seq, nfrom_emp_seq, message_status);
        }

        //public string SelectRecentInsertedRoleSeq()
        //{
        //    return dal.SelectRecentInsertedRoleSeq();
        //}

        public M_MessageReply GetInfo(string seq)
        {
            int nSeq;
 
            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public IList<M_MessageReply> GetInfoFromMoneyReqSeq(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfoFromMoneyReqSeq(nSeq);
            }
            else
            {
                return null;
            }
        }

        public M_MessageReply GetInfoFromSendSeq(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfoFromSendSeq(nSeq);
            }
            else
            {
                return null;
            }
        }

        public string Insert(M_MessageReply info)
        {
            try
            {
                return dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_MessageReply info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_MessageReply info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }

        public void UpdateMessageStatus(M_MessageReply info)
        {
            try
            {
                dal.UpdateMessageStatus(info);
            }
            catch
            {
                throw;
            }
        }
    }
}
